import "../style/index.scss"
import { _test } from "./common/Main"
import Record from './common/Record'
_test.Main.instance.initStoreMap({
  activityID: 10092,
  fbId: 1088475561284955,
  version: "de",
  fbRedirectUrl: fbRedirectUrl.index
})
_test.Main.instance.init()
Record.instance.init()

/**
 * please code your code below
 */

import Utils from 'common/Utils'
import Store from "common/Store";

var dom = {
  navIndexItem: $('.nav-index .item .hover'),
  window: $(window)
}
var functions = {
  navIndexItemHoverIn: function (e) {
    var target = $(e.target)
    var item = target.parent()
    item.addClass('hover')
    item.find('.cell').removeClass('hide')
  },
  navIndexItemHoverOut: function (e) {
    var target = $(e.target)
    var item = target.parent()
    item.removeClass('hover')
    item.find('.cell').addClass('hide')
  },
}
dom.navIndexItem.hover(functions.navIndexItemHoverIn, functions.navIndexItemHoverOut)

var heights = [document.querySelector('.event1 .title'), document.querySelector('.event2 .title'), document.querySelector(
  '.event3 .title')].map(
    item => {
      return Utils.instance.getElementTop(item)
    })
dom.navIndexItem.click(e => {
  var index = <any>e.target.dataset.index * 1
  if (index === 3) {
    window.open('https://www.facebook.com/TrainerBattle/')
  } else {
    var height = heights[index]
    dom.window.scrollTop(height)
  }

})


Record.instance.init()
